<template lang="pug">
  d2-container(:filename="filename")
    span {{querying ? "帖子详细加载中..." : (post.postTitle ? postTitle : "<无标题帖子>")}}
    el-row
        el-col(:span="6")
            img(:src="post.avatar")
            el-button() {{post.wxUName}}
        el-col(:span="18")
            h2 {{ post.postTitle ? post.postTitle : "<无标题帖子>" }}
            el-row
                el-col(:span="5")
                    span 分区:{{post.pName}}
                el-col(:span="5")
                    span 话题:{{post.tName}}
                el-col(:span="5")
                    span 创建时间:{{post.postCreateAt}}
                el-col(:span="3")
                    span 收藏量:
                el-col(:span="3")
                    span 点赞量:
                el-col(:span="3")
                    span 阅读量:
            p(v-html="post.postContent")
        
      

</template>

<script>
import Vue from "vue";
import { RefreshButton } from "@/components/aws-comp";

import axios from '@/plugin/axios'

export default {
  name: "post-index",
  data() {
    return {
      filename: __filename,
      querying: false,
      post:{}
    };
  },
  methods: {
    getPost(postId){
        const options = {url: 'admin/post/detail', method: "post", data:{postId}}
        this.querying = true
        axios(options).then(this.getPostFinished).catch(()=>{}).then(()=>(this.querying=false))
    },
    getPostFinished(post){
        this.post = post
    }
  },
  created(){
    const postId = this.$route.query.postId;
    this.getPost(postId);
  }
};
</script>